package cn.hp.customer.util;

import javax.xml.crypto.Data;

// 作为后端的响应结果对象
public class ResponseData {

    private int code ;
    private String msg ;
    private Object data ;

    private ResponseData(int code , String msg , Object data ){
        this.code = code ;
        this.msg = msg ;
        this.data = data ;
    }

    // 响应成功的结果
    public static ResponseData success(){
        return new ResponseData(ResponseStatus.SUCCESS.getCode() , ResponseStatus.SUCCESS.getMessage() , null);
    }

    // 响应成功的结果
    public static ResponseData success(Object data){
        return new ResponseData(ResponseStatus.SUCCESS.getCode() , ResponseStatus.SUCCESS.getMessage() , data);
    }

    // 响应失败的结果
    public static ResponseData fail(){
        return new ResponseData(ResponseStatus.FAIL.getCode() , ResponseStatus.FAIL.getMessage() , null );
    }

    // 带参失败
    public static ResponseData fail(String msg){
        return new ResponseData(ResponseStatus.FAIL.getCode() ,msg, null );
    }
    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }




}
